<%-- 
    Document   : list
    Created on : Jan 4, 2010, 11:07:32 AM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<script type="text/javascript">
    function toggleAll(name, checked){
        var checkboxes = document.getElementsByName(name);
        for (var i=0; i<checkboxes.length; i++){
            checkboxes[i].checked = checked;
        }
    }

    function setAdd(questionAutoId){
        document.getElementsByName("idToAdd").item(0).value = questionAutoId;
    }

    function confirmRemove(questionAutoId){
        if (confirm("Do you want to remove this question?")){
            setRemove(questionAutoId);
            return true;
        }
        return false;
    }

function setRemove(questionAutoId){
    document.getElementsByName("idToRemove").item(0).value = questionAutoId;
}



</script>
<form method="post">
    <input type="hidden" name="idToRemove"/>
    <table border="1">
        <tr>
            <td colspan="2">Select a category </td>
        </tr>
        <tr>
            <td colspan="2">
                ${class.sgt.onlinetest.util.HtmlExtensions.getCategoryTreeHTML$[catParent]["?catId=%d"]}
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <table border="1">
                    <tr>
                        <th colspan="6">Select questions to be used in the test</th>
                    </tr>
                    <tr>
                        <th>
                            <input name="checkAll" onclick="toggleAll('idToRemoveMany', this.checked)" type="checkbox" /></th>
                        <th>No.</th>
                        <th>Content</th>
                        <th>Type</th>
                        <th></th>
                        <th></th>
                    </tr>
                    <c:forEach var="question" items="${questions}" varStatus="counter">
                        <tr>
                            <td>
                                <input name="idToRemoveMany" type="checkbox" value="${question.autoId}" /></td>
                            <td>${counter.count}</td>
                            <td>${question.content}</td>
                            <td>${question.descriptiveType}</td>
                            <td><a href="#">Preview</a></td>
                            <td><a href="<%=request.getContextPath()%>/question/edit?id=${question.autoId}">Edit</a></td>
                            <td><input name="remove" type="submit" value="Remove" onclick="return confirmRemove(${question.autoId});"/> </td>
                        </tr>
                    </c:forEach>
                    <tr>
                        <td colspan="6">
                            <a href="<%=request.getContextPath()%>/question/edit?catId=${catParent.autoId}">Add new question</a>
                            <input type="submit" name="removeMany" value="Remove all checked" onclick="return confirm('Remove all checked questions?')"/></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</form>